package com.ys.controller.web.overseas;

import com.bo.vo.W;
import com.ys.config.MenuId;
import com.ys.entity.overseas.TosPlatformInformation;
import com.ys.service.sys.CommonApiService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: fxz
 * @CreateTime: 2024-12-17
 * @Description: HW平台信息维护WEB
 * @Version: 1.5
 */
@Controller
@RequestMapping("/web/overseas/tosPlatformInformation")
public class WebTosPlatformInformationController {
    private static final Logger logger = LoggerFactory.getLogger(WebTosPlatformInformationController.class);


    @Autowired
    private CommonApiService<TosPlatformInformation> commonApiService;

    Long MENUID = MenuId.TOS_PlatformInformation;

    /*
     * 新增
     */
    @RequiresPermissions("tosPlatformInformation:add")
    @GetMapping("/toAdd")
    public String toAdd(Model model, HttpServletRequest request, HttpServletResponse response){
        try {
            TosPlatformInformation entity = new TosPlatformInformation();
            entity.setStatus(1);
            return commonApiService.toAdd(model, entity, MENUID, null, null);

        } catch (Exception e) {
            e.printStackTrace();
            return W.error(model, e.getMessage());
        }
    }

    /*
     * 修改
     */
    @RequiresPermissions("tosPlatformInformation:edit")
    @GetMapping("/toEdit")
    public String toEdit(Model model, HttpServletRequest request, HttpServletResponse response,
                         Long id){

        TosPlatformInformation entity = new TosPlatformInformation().setId(id).queryFirst();

        try {
            return  commonApiService.toEdit(model, id, new TosPlatformInformation(), MENUID, null, null);
        } catch (Exception e) {
            e.printStackTrace();
            return W.error(model, e.getMessage());
        }
    }

    /*
     * 详情页
     */
    @RequiresPermissions("tosPlatformInformation:view")
    @GetMapping("/toDetail")
    public String toDetail(Model model, HttpServletRequest request, HttpServletResponse response,
                           Long id){

        TosPlatformInformation entity = new TosPlatformInformation().setId(id).queryFirst();

        try {
            return  commonApiService.toDetail(model, id, new TosPlatformInformation(), MENUID, null, null);
        } catch (Exception e) {
            e.printStackTrace();
            return W.error(model, e.getMessage());
        }
    }
}
